package com.yu.myiptv;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class ChannelDatabaseHelper extends SQLiteOpenHelper {
    private static final String DATABASE_NAME = "channels.db";
    private static final int DATABASE_VERSION = 1;

    public ChannelDatabaseHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String CREATE_TABLE = "CREATE TABLE channels (" +
                "_id INTEGER PRIMARY KEY AUTOINCREMENT," +
                "channel_id TEXT UNIQUE," +
                "name TEXT NOT NULL," +
                "url TEXT NOT NULL" +
                ")";
        db.execSQL(CREATE_TABLE);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        // 简单版本，实际应用中应添加数据迁移逻辑
        db.execSQL("DROP TABLE IF EXISTS channels");
        onCreate(db);
    }
}
